﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace FXC.SL.CS.Util
{
    public class Constants
    {
        public const string DockPanelSetting = "DockPanelSetting";

        public const string IsRememberLoginInfo = "IsRememberLoginInfo";
        public const string LogedInUserPWD = "LogedInUserPWD";
        public const string LogedInUserName = "LogedInUserName";
        public const double StandardZoom = 0.65;

        //public const Color DefaultBackGround = Colors.White;
        //public static Color DefaultBackgroundColor = Colors.White;
        //public static Color DefaultForegroundColor = Colors.Black;
        //public static Color DefaultGridColor = Colors.LightGray;
        //public static Color DefaultBarStrokeColor = Color.FromArgb(255, 255, 0, 0);
        //public static Color DefaultBarFillColor = Color.FromArgb(255, 0, 255, 0);
        //public static Color DefaultLineTypeColor = Color.FromArgb(255, 0, 255, 0);
        //public static Color DefaultVolumeColor = Color.FromArgb(255, 50, 205, 50);

        public static double GetPeroidStepByPeroidType(PeriodType periodType)
        {
            var ret = 0.0;

            switch (periodType)
            {
                case PeriodType.T_1M:
                    ret = DateTime.Now.ToOADate() - DateTime.Now.AddMinutes(-1).ToOADate();
                    break;
                case PeriodType.T_5M:
                    ret = DateTime.Now.ToOADate() - DateTime.Now.AddMinutes(-5).ToOADate();
                    break;
                case PeriodType.T_15M:
                    ret = DateTime.Now.ToOADate() - DateTime.Now.AddMinutes(-15).ToOADate();
                    break;
                case PeriodType.T_30M:
                    ret = DateTime.Now.ToOADate() - DateTime.Now.AddMinutes(-30).ToOADate();
                    break;
                case PeriodType.T_1H:
                    ret = DateTime.Now.ToOADate() - DateTime.Now.AddMinutes(-60).ToOADate();
                    break;
                case PeriodType.T_4H:
                    ret = DateTime.Now.ToOADate() - DateTime.Now.AddMinutes(-240).ToOADate();
                    break;
                case PeriodType.T_1D:
                    ret = DateTime.Now.ToOADate() - DateTime.Now.AddDays(-1).ToOADate();
                    break;
                case PeriodType.T_1W:
                    ret = DateTime.Now.ToOADate() - DateTime.Now.AddDays(-7).ToOADate();
                    break;
                case PeriodType.T_1MN:
                    ret = DateTime.Now.ToOADate() - DateTime.Now.AddMonths(-1).ToOADate();
                    break;
            }

            return ret;

        }

        public static PeriodType GetPeroidTypeByString(string val)
        {
            switch (val)
            {
                case "1M":
                    return PeriodType.T_1M;
                case "5M":
                    return PeriodType.T_5M;
                case "15M":
                    return PeriodType.T_15M;
                case "30M":
                    return PeriodType.T_30M;
                case "1H":
                    return PeriodType.T_1H;
                case "4H":
                    return PeriodType.T_4H;
                case "1D":
                    return PeriodType.T_1D;
                case "1W":
                    return PeriodType.T_1W;
                case "1MN":
                    return PeriodType.T_1MN;
                default:
                    throw new ArgumentException("Period Type string is invalid");
            }
        }
    }
}
